<!--
 * @Description: ...
 * @Author: yangli 121029539@qq.com
 * @Date: 2025-02-06 11:23:56
 * @LastEditTime: 2025-02-18 17:29:43
 * @LastEditors: yangli 121029539@qq.com
 * @FilePath: \uniapp\src\pages\index\repair.vue
-->
<template>
    <view class="bg-page">
        <u-tabs class="base-tabs" :list="tabList" :is-scroll="false" v-model="current" @change="handleChange"
            activeColor="var(--color-primary)" inactive-color="#606266" font-size="32"></u-tabs>
        <view class="page-list tabs mt-[10px]">
            <z-paging auto-show-back-to-top ref="paging" v-model="dataList" @query="queryList" :fixed="false"
                height="100%">
                <view class="mb-[10px] bg-white p-[32rpx]" @tap="onItemClick(item)" v-for="(item, index) in dataList"
                    :key="index">
                    <view class="flex flex-row items-start">
                        <image :src="item.insurance.img" class="w-[140rpx] h-[140rpx] rounded-[8rpx]"></image>
                        <view class="flex flex-col flex-1 ml-[20px]">
                            <view>
                                编号 :{{ item.order_no }}
                            </view>
                            <view class=" flex flex-row justify-between items-center self-stretch text-base">
                                <view class=" self-center max-w-[350rpx]  text-main">
                                    {{ item.spec }}</view>

                                <view class="self-start">
                                    <text class="text-success">{{ item.status_desc }}</text>
                                </view>
                            </view>
                            <view class="mb-1">
                                类型:{{ item.insurance.name }}
                            </view>
                            <view class=" ">
                                <text class="text-muted">报修时间：</text>
                                <text class="text-c3">{{ item.create_time }}</text>
                            </view>
                        </view>
                    </view>
                </view>
            </z-paging>
        </view>
    </view>
</template>

<script setup lang="ts">
import { repairList } from '@/api/repair'
import { onLoad, onShow, onPageScroll } from '@dcloudio/uni-app'
import { computed, reactive, ref, shallowRef, nextTick } from 'vue'
import { useAppStore } from '@/stores/app'
import { useUserStore } from '@/stores/user'
import { times } from 'lodash-es'

const appStore = useAppStore()
const userStore = useUserStore()
const token = computed(() => userStore.token)
const tabList = [
    { name: '全部', status: -1 },
    { name: '待寄送', status: 0 },
    { name: '维修中', status: 15 },
    { name: '已完成', status: 20 }
]

const current = ref<number>(0)
const paging = shallowRef<any>(null)
const dataList = ref<any[]>([])
const state = reactive({})

const handleChange = (index: number) => {
    current.value = Number(index)
    paging.value.reload()
}
function onItemClick(item: any) {
    uni.navigateTo({
        url: `/pagesrepair/repairdetail?id=${item.id}`
    })
}
const queryList = async (page_no: number = 1, page_size: number = 10) => {
    try {
        const { data } = await repairList({
            page_no,
            page_size,
            status: tabList[current.value].status
        })
        paging.value.complete(data)
    } catch (e) {
        console.log('报错=>', e)
        paging.value.complete(false)
    }
}

onLoad(() => { })
onShow(async () => {
    // await nextTick()
    // paging.value.reload();
})
</script>

<style lang="scss" scoped></style>
